package sgc.util;

import javax.faces.context.FacesContext;

import sgc.beans.CheckUserBean;

public class Util {
	
	public static int act_company() {
		int company;
		company = 0;
		try {
			FacesContext context = FacesContext.getCurrentInstance();
			CheckUserBean cu = (CheckUserBean) context.getApplication()
					.evaluateExpressionGet(context, "#{checkUserBean}",
							CheckUserBean.class);
			company = cu.getUsuario().getCompany_code();
		} catch (Exception e) {
		}
		return company;

	}

	public static java.sql.Date convertDate(java.util.Date jDate) {
		java.sql.Date sqlDate;
		long t;

		if (jDate == null) {
			sqlDate = new java.sql.Date(0);
		} else {
			t = jDate.getTime();
			sqlDate = new java.sql.Date(t);
		}
		return sqlDate;
	}

	public static String parseStr(String campo) {
		String delims = " - ";
		String[] tokens = campo.split(delims);

		return tokens[0];
	}

	public static int parseInt(String campo) {
		String delims = " - ";
		String[] tokens = campo.split(delims);

		return Integer.parseInt(tokens[0]);
	}

}
